package com.yswy.backstage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yswy.backstage.service.TgChannelService;
import com.yswy.backstage.service.TgEventService;
import com.yswy.domain.entity.tf.TgEvent;
import com.yswy.domain.vo.dto.BaseFilter;
import com.yswy.domain.vo.gld.addOrUpate.TgChannelAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.TgEventAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.base.BaseReqVO;
import com.yswy.domain.vo.gld.list.TgChannelList;
import com.yswy.domain.vo.gld.search.TgChannelSearch;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


@RestController
@RequestMapping("/tgChannel")
@Api(tags = "检测链接")
public class TgChannelController {

    @Autowired
    private TgChannelService tgChannelService;


    @PostMapping("/pageTgChannel")
    @ApiOperation(value = "检测链接列表")
    public Page<TgChannelList> pageTgChannel(@RequestBody  TgChannelSearch req, HttpServletRequest request) {
        return tgChannelService.pageTgChannel(req);
    }


    @GetMapping("/isExistTgChannel")
    @ApiOperation(value = "判断检测链接渠道是否存在")
    public Boolean isExistTgChannel(@RequestParam(value = "channel") String channel,
                        HttpServletRequest request) {
        return tgChannelService.isExistTgChannel(channel);
    }

    @PostMapping("/addTgChannel")
    @ApiOperation(value = "添加检测链接")
    public void addTgChannel(@RequestBody @Validated(BaseReqVO.CREATE.class) TgChannelAddOrUpdate req, HttpServletRequest request) {
        tgChannelService.addTgChannel(req);
    }

    @PostMapping("/updateTgChannel")
    @ApiOperation(value = "修改检测链接")
    public void updateTgChannel(@RequestBody @Validated(BaseReqVO.UPDATE.class) TgChannelAddOrUpdate req, HttpServletRequest request) {
        tgChannelService.updateTgChannel(req);
    }

    @GetMapping("/delTgChannel")
    @ApiOperation(value = "删除检测链接")
    public void delTgChannel(@RequestParam(value = "tgChannelId") Long tgChannelId,
                                   HttpServletRequest request) {
        tgChannelService.delTgChannel(tgChannelId);
    }


}
